Skip to content

refactor: extract transformers and claim modules from storage.ts#133

Merged
coji merged 1 commit intomainfrom
refactor/storage-extract-modules
Mar 16, 2026
Merged

refactor: extract transformers and claim modules from storage.ts#133
coji merged 1 commit intomainfrom
refactor/storage-extract-modules

Conversation

@coji
Copy link
Owner

@coji coji commented Mar 16, 2026

Summary

Improve storage.ts cohesion by extracting modules with clear responsibilities:

File Lines Responsibility
storage.ts 876 (-18%) Store interface, CRUD, lease management
transformers.ts 71 Pure data transformation (row → domain objects)
claim-postgres.ts 95 PostgreSQL claim (SKIP LOCKED + advisory locks)
claim-sqlite.ts 54 SQLite claim (atomic UPDATE subquery)

Each claim module is independently readable and testable. claimNext in storage.ts delegates to the appropriate backend module.

Closes #131

Test results

  • SQLite: 161 passed
  • PostgreSQL: 11 passed
  • Browser: all passed

🤖 Generated with Claude Code

storage.ts: 1063 → 876 lines (-18%)

Extracted:
- transformers.ts (71 lines): rowToRun, rowToStep, rowToLog, validateLabels
  Pure data transformation, zero DB dependency.
- claim-postgres.ts (95 lines): FOR UPDATE SKIP LOCKED + advisory locks
- claim-sqlite.ts (54 lines): atomic UPDATE with subquery

claimNext in storage.ts now delegates to the appropriate backend module.
Each file has a single, clear responsibility.

Closes #131

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

Warning

Rate limit exceeded

@coji has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 22 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9021e808-9d72-467c-b54e-8a55a3aaf869

📥 Commits

Reviewing files that changed from the base of the PR and between b4fc102 and 96ffa72.

📒 Files selected for processing (4)
  • packages/durably/src/claim-postgres.ts
  • packages/durably/src/claim-sqlite.ts
  • packages/durably/src/storage.ts
  • packages/durably/src/transformers.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/storage-extract-modules
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
durably-demo Ready Ready Preview Mar 16, 2026 0:33am
durably-demo-vercel-turso Ready Ready Preview Mar 16, 2026 0:33am

@coji coji merged commit 7d09841 into main Mar 16, 2026
5 checks passed
@coji coji deleted the refactor/storage-extract-modules branch March 16, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: improve storage.ts cohesion by extracting modules

1 participant